package dao

import (
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
	"time"
)

type UsersHis struct {
	Id        int       `json:"id" gorm:"primary_key" description:"自增主键"`
	SelfId    string    `json:"self_id" gorm:"column:self_id" description:"self_id"`
	Type      string    `json:"type" gorm:"column:type" description:"type"`
	Point     string    `json:"point" gorm:"column:point" description:"point"`
	Explains  string    `json:"explains" gorm:"column:explains" description:"explains"`
	Picwords  string    `json:"picwords" gorm:"column:picwords" description:"picwords"`
	Daan      string    `json:"daan" gorm:"column:daan" description:"daan"`
	Imgsrc    string    `json:"imgsrc" gorm:"column:imgsrc" description:"imgsrc"`
	QuestId   int       `json:"quest_id" gorm:"column:quest_id" description:"quest_id"`
	CreatedAt time.Time `json:"created_at" gorm:"column:created_at" description:"创建时间"`
	UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at" description:"更新时间"`
}

func (t *UsersHis) TableName() string {
	return "edt_users_his"
}

func (t *UsersHis) AddData(c *gin.Context, tx *gorm.DB, data *UsersHis) (*UsersHis, error) {
	err := tx.WithContext(c).Create(data).Error
	if err != nil {
		return nil, err
	}
	return data, nil
}
